package com.blackhorse.service;

import com.blackhorse.domain.Order;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;


/**
 * 用户下单完成后，通过消费下单MQ，给用户发短信
 */
@Slf4j
@Service
@RocketMQMessageListener(
        consumerGroup = "shop-user",  //消费者组名
        topic = "order-topic", //消费主题
        consumeMode = ConsumeMode.CONCURRENTLY, //指定消费模式，默认CONCURRENTLY并发消费，可设置为ORDERLY顺序消费
        messageModel = MessageModel.CLUSTERING //指定消息模式，默认CLUSTERING集群模式，可设置为BROADCASTING广播模式
)
public class SmsService implements RocketMQListener<Order> {

    @Override
    public void onMessage(Order order) {
        log.info("收到一个订单消息{}，准备给用户发送短信", order);
    }
}
